package cn.fbs.controller.core;

import cn.fbs.model.TVideoInfo;
import cn.fbs.param.SearchParam;
import cn.fbs.param.VideoParam;
import cn.fbs.service.core.VideoService;
import cn.fbs.vo.QueryVideoVo;
import cn.fbs.vo.TVideoInfoVo;
import cn.fbs.vo.TVideoItemVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

import static cn.fbs.util.RequestUtils.getUserName;

public class VideoController {

    @Autowired
    private VideoService videoService;

    @ApiOperation("ZC视频检索  --新")
    @GetMapping("imageData/queryVideoByParams")
    public List<TVideoInfo> queryVideoByParams(QueryVideoVo videoVo) {
        List<TVideoInfo> list = videoService.queryVideoByParam(videoVo);
        return list;
    }

    @ApiOperation("编辑ZC视频")
    @PostMapping("imageData/updateZCVideo")
    public String updateZCVideo(@RequestBody VideoParam uploadParam, HttpServletRequest request) {
        uploadParam.setIsExamine(null);
        uploadParam.setOperator(getUserName(request));
        return videoService.updateZCVideo(uploadParam);
    }

    @ApiOperation("ZC视频搜索")
    @GetMapping("imageData/searchVideo")
    public List<TVideoInfoVo> SearchVideo(SearchParam searchParam) throws IOException {
        return videoService.SearchVideo(searchParam);
    }


    @ApiOperation("ZC视频基本详情")
    @GetMapping("imageData/ZCVideoItem")
    @ApiImplicitParam(name = "id", value = "视频ID")
    public TVideoItemVo getVideoItem(@RequestParam("id") Integer id) {
        return videoService.getVideoItem(id);
    }


    @ApiOperation("新增ZC视频")
    @PostMapping("imageData/addZCVideo")
    public String addZCVideo(@RequestBody VideoParam uploadParam,HttpServletRequest request) {
        uploadParam.setId(null);
        uploadParam.setIsExamine(1);
        uploadParam.setOperator(getUserName(request));
        return videoService.uploadVideo(uploadParam);
    }

}
